import request from "@/util/request.js"

/**
 * 添加spu与sku数据
 * @param {*} spu 
 * @param {*} skus 
 * @returns 
 */
const add = (spu,skus=[])=>{
    return request({
        url:"Spu",
        method:'post',
        data:{spu,skus}
    })
}

const getAll = (query)=>{
    return request({
        url:"Spu",
        params:query
    })
}

/**
 * 根据id获取
 * @param {} id 
 * @returns 
 */
const getById = (id)=>{
    return request({
        url:"Spu/getById",
        params:{id:id}
    })
}

const update = (data)=>{
    return request({
        url:"Spu/update",
        data:data,
        method:"post"
    })
}

export default {
    getAll,
    add,
    getById,
    update
}